<?php

    // redimensionnement des images + effets
	require_once(realpath(dirname(__FILE__)) . "/divers.php");

	 // Déclaration des variables
	 $vars = array('type', 'nomorig', 'height', 'width', 'opacite', 'nb', 'miroir');

	 foreach($vars as $var)
	 {
		if (isset($_REQUEST[$var]))
			$$var = $_REQUEST[$var];
		else
			$$var = '';
	 }

	 $nomcache = redim($type, $nomorig, $width, $height, $opacite, $nb, $miroir);

	 if ($nomcache != '' && preg_match("/([^\/]*).((jpg|gif|png|jpeg))/i", $nomorig, $nsimple))
	 {
	      switch(strtolower($nsimple[2]))
	      {
	        case "gif" :
	            header("Content-type: image/gif");
	        break;

	        case "jpg":
	        case "jpeg":
	            header("Content-type: image/jpeg");
	        break;

	        case "png":
	            header("Content-type: image/png");
	        break;

	        default:
	        	exit();
	      }

	      if ($stat = @stat("../$nomcache"))
	      {
	      	header('Last-Modified: '.date('r', $stat['mtime']));
       	  	header('Content-Length: '.$stat['size']);
	      }

	      readfile("../$nomcache");
	 }
 ?>